package main

import "fmt"

func main() {
	var a int8 = -10
	var b int8 = 5
	var ua uint8 = uint8(a)
	var ub uint8 = uint8(b)
	fmt.Printf("a = %d, b = %d\n", a, b)
	fmt.Printf("ua = %d, ub = %d\n", ua, ub)

	// 1. 运算和符号无关. Print 输出数字，需要显式告诉它是否有无符号。
	c := a + b
	fmt.Printf("c = a + b = %d\n", c)
	fmt.Printf("uint8(c) = %d\n", uint8(c))

	uc := ua + ub
	fmt.Printf("uc = ua + ub = %d\n", uc)
	fmt.Printf("int8(uc) = %d\n", int8(uc))

	// 2. 比较大小和符号有关
	var x bool = a < b
	fmt.Printf("a < b = %v\n", x)
	fmt.Printf("ua < ub = %v\n", ua < ub)
}
